home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 12 / Cream of the Crop 12 (Part II) / Cream of the Crop 12 (Part II).iso / OS2 / WHOAMI11.ZIP / WHOAMI.DOC < prev    next >
Encoding:
Text File  |  1996-04-08  |  3.6 KB  |  104 lines

  1. WHOAMI and PMWHOAMI for 32-bit OS/2 v1.1
  2.  
  3. Here's another simplistic but useful-beyond-words program.
  4.  
  5. This program will tell you what your current domain name and IP address is.
  6. Granted, this won't do you ANY good unless you are connected to some sort of
  7. TCP/IP (Internet-type) network, by SLIP, PPP, or other means.
  8.  
  9. Usage is like so:
  10. whoami.exe [/K] [/HOST | /IP]
  11.  
  12. It will return something along these lines:
  13.  
  14. foo.bar.com (205.184.158.43)
  15.  
  16. or (if you specified whoami /IP)
  17.  
  18. 205.184.158.43
  19.  
  20. OR... (if you specified whoami /HOST)
  21.  
  22. foo.bar.com
  23.  
  24.  
  25. to stdout. ...So you can redirect this output elsewhere, for logging or use
  26. with a batch file or piped to another program. The possibilities are endless.
  27.  
  28. The optional "/K" command line sets the 'KEEP GOING' option, where, in case
  29. hostname information can't be retrieved, this program will continue to attempt
  30. to retrieve it until it either it has, or you shutdown the program.
  31.  
  32. What good is that? I'm glad you asked. Let's say you have a bunch of programs
  33. that you don't want to run until after you've connected, such as an email
  34. client. Do this: make a .cmd file...goppp.cmd, for example:
  35.  
  36. @echo off
  37. start /min myprogs.cmd
  38. SLIPPM
  39.  
  40.  
  41.  
  42. ...and myprogs.cmd...
  43.  
  44. whoami /k
  45. rem Nothing below this line runs until whoami returns (we're connected.)
  46.  
  47. etc...
  48.  
  49.  
  50.  
  51. Now, rather than call SLIPPM.EXE (the 'dial other internet providers' icon),
  52. call goppp.cmd.
  53.  
  54. ok, so it's complicated. :)  But besides that, it's still handy.
  55.  
  56. In case you missed it, specifying a /HOST on the command line will give you
  57. just the domain name (foo.bar.com...or whatever...the 'english' version of
  58. /IP), and /IP on the command line will return just the IP address (those
  59. four numbers, separated by periods.)
  60.  
  61. Also, there is a Presentation Manager application version of this included,
  62. called PMWHOAMI.EXE. This is prettier, but can't be redirected. (it ain't
  63. stdout...) Also, the trick I just illustrated above won't work as well with
  64. the PM version...although it accepts the "/K" command line in the same fashion,
  65. you'd have to exit the program before the batch file could continue. However,
  66. it is prettier to look at. (and /HOST or /IP work with it.)
  67.  
  68. Oh, if the HOSTNAME variable is set, you can lie to this program. if you
  69. SET HOSTNAME=voicenet.com
  70.  
  71. and then run whoami.exe, you'll get this:
  72. voicenet.com  (192.204.28.35)
  73.  
  74.  
  75. WHOAMI Compatibility: This should work with OS/2 2.0 and higher with some
  76.                       sort of TCP/IP support.
  77.  
  78. Finally, the entire source code is included. I wrote this using EMX 0.9b, and
  79. BSD sockets (available from ftp://hobbes.nmsu.edu/os2/unix/emx09b/). However,
  80. I make no claim that this is 'Good' or 'clean' coding. I tried to, through a
  81. bunch of #ifdefs, put the VIO and PM versions of this program in the same
  82. source file. It's kinda messy, and there are a few kludges to accomodate both
  83. versions...regardless of this programming experiment, it works.
  84.  
  85. This program if freeware. If you get any use out of it, I would appreciate an
  86. email telling me you like it (mailto:warped42@ix.netcom.com), or an email
  87. telling me you hate it...
  88.  
  89. Enjoy.
  90.  
  91.                                  --Ryan C. Gordon (warped42@ix.netcom.com)
  92.  
  93.  
  94. --------------
  95. Version history:
  96.  v1.0 : It works. It works well.
  97.  v1.1 : Added /IP and /HOST command line options.
  98.         Would like to add an /EIP, /EHOST and /EALL (or something like that)
  99.            that'll SET this information in an Environment variable for the
  100.            current session. Anyone know what API can do this?
  101.         Shrunk code a BUNCH through various compiler options and .DEF file
  102.            instructions.
  103. --------------
  104.